package game;

import java.util.Random;

/**
 * Task Factory - to create a task.
 * @author Natchanon Hongladaromp
 */
public class TaskFactory
{
	/**
	 * Returns random numbers.
	 * @param n number of numbers to random
	 * @return random numbers
	 */
	private static int[] randomNumbers(int n)
	{
		int[] numbers = new int[n];
		long seed = System.nanoTime();
		Random random = new Random(seed);
		for (int i = 0; i < n; i++)
		{
			numbers[i] = random.nextInt(9) + 1;
		}

		return numbers;
	}
	
	/**
	 * Creates new task.
	 * @return task
	 */
	public static Task createTask()
	{
		Task task;
		do{
			task = new Task(randomNumbers(4));
		}while(!task.isPossible());
		return task;
	}
}
